//
//  TestViewController.m
//  FLHBaseProject
//
//  Created by fance on 16/5/31.
//  Copyright © 2016年 Fance. All rights reserved.
//

#import "TestViewController.h"

@interface TestViewController (){
    
    __weak IBOutlet UITextField *nTextField;
    __weak IBOutlet UITextField *mTextField;
    __weak IBOutlet UIButton *mTestBtn;
}

@end

@implementation TestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    // mTestBtn.titleEdgeInsets = UIEdgeInsetsMake(71, -mTestBtn.titleLabel.bounds.size.width-50, 0, 0);
    // mTestBtn.imageEdgeInsets = UIEdgeInsetsMake(5,13,21,mTestBtn.titleLabel.bounds.size.width);//设置image在button上的位置（上top，左left，下bottom，右right）这里可以写负值，对上写－5，那么image就象上移动5个像素
   // mTestBtn.titleEdgeInsets = UIEdgeInsetsMake(10, 0, 20, 5);
    CGFloat imageWidth = mTestBtn.imageView.bounds.size.width;
    CGFloat labelwidth = mTestBtn.titleLabel.bounds.size.width;
    mTestBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -imageWidth, 0, imageWidth);
    mTestBtn.imageEdgeInsets = UIEdgeInsetsMake(0, labelwidth, 0, -labelwidth);

    [mTextField addTarget:self action:@selector(mTextFiledAction) forControlEvents:UIControlEventEditingChanged];
     [nTextField addTarget:self action:@selector(mTextFiledAction) forControlEvents:UIControlEventEditingChanged];
    
    mTestBtn.backgroundColor = GRAYCOLOR;
    //串行队列
//    dispatch_queue_t queue = dispatch_queue_create("tk.bourne.testQueue", NULL);
//    dispatch_queue_t queue2 = dispatch_queue_create("tk.bourne.testQueue", DISPATCH_QUEUE_SERIAL);
//    //并行队列
//    dispatch_queue_t queue3 = dispatch_queue_create("tk.bourne.testQueue", DISPATCH_QUEUE_CONCURRENT);
    
    // 创建队列
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
   
    
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW,(int64_t)(3 * NSEC_PER_SEC)), queue, ^{
      // 延迟3s
  });
    
// 测试一下
    
}

-(void)mTextFiledAction{
    
    if (mTextField.text.length > 6 && nTextField.text.length > 0) {
        mTestBtn.backgroundColor = [UIColor orangeColor];
    }else{
        mTestBtn.backgroundColor = [UIColor clearColor];
    }
   
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
